/*
 * Created on Mon Jun 11 2018 by Ronnie Ren (zhaosong.ren) from Accenture
 *
 * Copyright (c) 2018 DingXin information & technology limited company.
 */

import { Application } from "../models/application";
import { Injectable } from "@angular/core";
import { HttpService } from "http-service";


export interface Category2Applications {
  name: string;
  apps: Array<Application>;
}


@Injectable()
export class ApplicationsService {

  constructor(private httpService: HttpService) {
    // TODO
  }

  fetchApplications(): Array<Category2Applications> {

    // TODO get it from server.
    let jsonApps: Array<{ name: string, apps: Array<{ id: string, name: string, appIconURL: string, "urlScheme": string }> }> =
      [{
        name: "专业应用",
        apps: [
          {
            id: "com.csg.gz.mobileark",
            name: "移动营销",
            urlScheme: "MobileArk",
            appIconURL: 'assets/imgs/com.csg.mobileark-60x60-2x.png'
          },
          {
            id: "com.csg.fprs",
            name: "抢修",
            urlScheme: "",
            appIconURL: "assets/imgs/com.csg.study-57x57-2x.png"
          },
          // {
          //   id: "com.csg.study",
          //   name: "巡视",
          //   urlScheme: "",
          //   appIconURL: "assets/imgs/com.csg.study-57x57-2x.png"
          // },
          // {
          //   id: "com.csg.study",
          //   name: "XXX",
          //   urlScheme: "",
          //   appIconURL: "assets/imgs/com.csg.study-57x57-2x.png"
          // }
        ]
      },
      {
        name: "公共应用",
        apps: []
      }
      ];


    return jsonApps.map((app) => {
      return {
        name: app.name, apps: app.apps.map(
          (appItem) => new Application(appItem.id, appItem.name, appItem["urlScheme"], appItem.appIconURL))
      };
    });


  }


}
